package com.jz.community.modulemine.presenter;

import com.jz.community.basecomm.mvp.BaseLifeCyclePresent;
import com.jz.community.basecomm.net.rxandroid.OnLoadListener;
import com.jz.community.modulemine.bean.UserChangeOtherBean;
import com.jz.community.modulemine.model.MineModel;
import com.jz.community.modulemine.model.MineModelImp;
import com.jz.community.modulemine.ui.changePasswordView;

/**
 * Created by Admin on 2018/4/8 0008.
 */

public class changePasswordPresenter extends BaseLifeCyclePresent<changePasswordView.View> implements changePasswordView.Presenter {


    private changePasswordView.View passwordView;
    private MineModel mineModel;

    public changePasswordPresenter(changePasswordView.View passwordView) {
        this.passwordView = passwordView;
        this.mineModel = new MineModelImp(passwordView.getContext());
    }

    @Override
    public void changePassword(String userId, String old_password, String password) {

        mineModel.changePassword(userId, old_password, password, new OnLoadListener<UserChangeOtherBean>() {
            @Override
            public void onSuccess(UserChangeOtherBean responseText) {
                passwordView.changePasswordResult(responseText);
            }

            @Override
            public void onFail(String s, int code) {
                passwordView.showError(s, code);
            }
        });
    }
}
